import { createStore } from 'vuex';
interface stateInterface {
  staticPath: string;
  materialImg: string;
  showActive: any; //跳转活动页返回时不弹出设备号弹框
  dingdingInfo: AnyObject; //authCode,token
}
export default createStore({
  state: {
    staticPath: 'https://h5.mythinkcar.cn/static/',
    materialImg: localStorage.getItem('materialImg') || '',
    showActive: true,
    dingdingInfo:
      JSON.parse(localStorage.getItem('dingdingInfo') as string) || {}
  } as stateInterface,

  mutations: {
    // 存储钉钉信息
    storeDingdingInfo(state, authInfo) {
      console.log('xxx', authInfo);

      Object.assign(state.dingdingInfo, authInfo);
      localStorage.setItem('dingdingInfo', JSON.stringify(state.dingdingInfo));
    },
    setMaterialImg(state, materialImg: string): void {
      state.materialImg = materialImg;
      localStorage.setItem('materialImg', materialImg);
    },
    changeShowActive(state, payload: any) {
      state.showActive = payload;
      sessionStorage.setItem('showActive', payload);
    }
  },

  actions: {},
  modules: {}
});
